﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using Dogshow.Web.Infrastructure;
using Dogshow.Web.Models;
using Dogshow.Web.Helpers;

namespace Dogshow.Web.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        [Authorize]
        public ActionResult Index()
        {
            return RedirectToAction("Index", "Home", new {Area = "Korisnik"});
        }

        public PartialViewResult UcitajNavigaciju()
        {
            var korisnik = Request.Cookies.VratiKorisnika();

            string path = null;
            if (korisnik.VrstaNaloga == 1)
            {
                path = Server.MapPath("~/App_Data/AdminMeni.xml");
            }
            else if (korisnik.VrstaNaloga == 2)
            {
                path = Server.MapPath("~/App_Data/KorisnikMeni.xml");
            }
            else
            {
                path = Server.MapPath("~/App_Data/KinoloskoDrustvoMeni.xml");
            }
            
            return PartialView("GlavnaNavigacija", path);
        }

        public ActionResult VratiKorisnika()
        {
            var korisnik = Request.Cookies.VratiKorisnika();
            return PartialView("Korisnik", korisnik);
        }

        public ActionResult OdjaviMe()
        {
            FormsAuthentication.SignOut();
            return RedirectToAction("Index", "Prijava");
        }
    }
}
